<template>
  <div>
 
    <register-top :info="topinfo"></register-top>
       <register-text
      label="用户名"
      placeholder="请输入您的用户名"
      rules=""
      @setContent="(val)=>username=val"
      style="margin-top:20px"
    ></register-text>
     <register-text
     type="password"
      label="密码"
      placeholder="请输入您的密码"
      rules=""
      @setContent="(val)=>password=val"
    ></register-text>
    <register-btn :current="openClose" btntext="登录" @onemit="LoginUser"></register-btn>
  </div>
</template>

<script>
import {mapMutations} from 'vuex'
import  RegisterBtn from '../../common/Login/LoginBtn.vue'
import RegisterText from '../../common/Login/LoginText.vue'
import RegisterTop from "../../common/Login/LoginTop.vue"
export default {
  data() {
    return {
        topinfo:{
            title:"登录bilibili",
            btn:"用户注册"
        },
        username:"",
        password:"",
        
    };
  },
  components: {
    RegisterTop,
    RegisterText,
    RegisterBtn
  },
  computed:{
      openClose(){
          return this.username !== '' && this.password !== ""
      }
  },
  methods:{
    ...mapMutations['setUser'],
    LoginUser(){
      let {username,password} = this
       sessionStorage.setItem('token',JSON.stringify({username,password,petname:"45744963276_bili",sex:1,brithday:"2000-12-06",desc:"",uid:"45744963276_bili"}))
        this.$router.push('userinfo')
       let token = JSON.parse(sessionStorage.getItem("token"))
      this.setUser(token)
     
     
      
    }
  }
};
</script>

<style lang="less" scoped>
</style>
